//1.
class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int n = nums.size();
        if(n==1)
            return 1;
        int slow = -1,fast=1;
       
        for(int i=1;i<n;++i) {
            if(nums[i]==nums[i-1]) {
                slow = i;
                break;
            }
        }
        if(slow==-1)
            return n;
        int flag=slow;
        fast=slow+1;
        while(fast < n) {  
            if(nums[fast] == nums[fast-1])                 
                fast++;
            else{
                nums[slow++] = nums[fast++];  
                flag++;                                      
            }
           
        }
        return flag;
    }
};